function login() {
    let da={
        username:$("#username").val(),
        password:$("#password").val(),
    };
    $.ajax({
        url:'http://localhost:8080/login',
        data:JSON.stringify(da),
        type:"post",
        contentType: "application/json; charset=UTF-8",
        dataType:'json',
        success:function (data) {
        if (data.data.start=="0") {
            localStorage.setItem("token",data.data.token);
            localStorage.setItem("username",$("#username").val());
            window.open("index.html");
        }else if (data.data.start=="1") {
            alert("登录失败，用户名或密码错误！");
        }else if (data.data.start=="2") {
            alert("账号被冻结，稍后再试！");
        }else if (data.data.start=="3") {
            alert("错误次数超过三次，账号已被冻结5分钟！");
        }
        }
    })
}




//点击切换验证码
function flashCode(objct) {
    $(objct).attr("src", "http://localhost:8080/code?date="+new Date());
}


//回车键触发事件
document.onkeydown =cdk;
function cdk(){
    if(event.keyCode ==13){
        login();
    }
}